#include "car_maintenance.hpp"
#include "file_list.hpp"

float car_maintenance_csv::total_amount(int _plate_id, boost::gregorian::date _first_date, boost::gregorian::date _last_date, bool _include_last_date)
{
		float amount(0);
	/*	csv_struct csv_file(file_list::car_maintenance_filename());
		
		while(!csv_file.eof())
		{
			++csv_file;
			car_maintenance_struct_csv row(csv_file.get_line());

			if(!this->check_parm(row, _plate_id, _first_date, _last_date, _include_last_date))
			{	
				continue;
			}	

			amount += row.totalAmount();
		}*/

		return amount;
}


bool car_maintenance_csv::check_parm(car_maintenance_struct_csv& row, 
		int _plate_id, boost::gregorian::date _first_date, boost::gregorian::date _last_date, bool _include_last_date)
{
		if(row.plateId() != _plate_id){ return false;} 					// check plate Id
		if(row.maintenanceDate() < _first_date) { return false; }                        // discard any date before
		if(row.maintenanceDate() > _last_date ){ return false; }                         // discard any date after
		if(row.maintenanceDate() == _last_date && !_include_last_date){  return false; } // is the last date to be considered?
		
		return true;
}